/**
 * 
 */
package com.cnhaimei.base;

import com.cnhaimei.vod.R;
import com.cnhaimei.vod.logic.EventsManager;
import com.cnhaimei.vod.net.XVod;
import com.cnhaimei.vod.util.Const;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;

/**
 * 对透明点击事件做拦截
 * 
 * @author Jin001.Wu@gmail.com <br>
 * @date 2011-7-4
 * 
 */
public abstract class TransparentActivity extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// setTheme(android.R.style.Theme_Translucent);
	}

	@Override
	public void onContentChanged() {
		super.onContentChanged();

		setClickable(R.id.translucent_bg, R.id.float_layout);
	}

	public void onClick(View v) {
		int id = v.getId();
		switch (id) {
		case R.id.float_layout:
			break;
		case R.id.translucent_bg:
			finish();
			break;
		default:
			break;
		}
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		registerReceiver(mBroadcastReceiver, new IntentFilter(Const.Recieve.ClickHome));
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		unregisterReceiver(mBroadcastReceiver);
	}

	private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
		@Override
		public void onReceive(Context context, Intent intent) {
			onClickHome();
		}
	};

	protected void onClickHome() {
		finish();
	}
}
